package com.atguigu.juc;

@FunctionalInterface
interface Animal{
    void eat();
}

@FunctionalInterface
interface Calculator{
    void cal(int i,int j);
}

public class LambdaTest {
    public static void main(String[] args) {
        // 匿名内部类的形式
        Animal animal1 = new Animal() {
            @Override
            public void eat() {
                System.out.println("cat eating...");
            }
        };
        animal1.eat();

        // lambda表达式得形式
        Animal animal2 = () -> {System.out.println("dog eating...");};
        animal2.eat();

        // 匿名内部内得形式
        Calculator calculator1 = new Calculator() {
            @Override
            public void cal(int i, int j) {
                System.out.println("i+j结果是："+(i+j));
            }
        };
        calculator1.cal(3,9);

        // lambda表达式得写法
        Calculator calculator2 = (int i,int j)->{
            System.out.println("i+j结果是："+(i+j));
        };
        calculator2.cal(8,0);

        Calculator calculator3 = (i,j)->{
            System.out.println("i+j结果是："+(i+j));
        };
        calculator2.cal(7,7);
    }
}
